import Vue from "vue";

import "normalize.css/normalize.css"; // A modern alternative to CSS resets

import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css";
import locale from "element-ui/lib/locale/lang/en"; // lang i18n

import "@/styles/index.scss"; // global css

import App from "./App";
import store from "./store";
import router from "./router";

import "@/icons"; // icon
import "@/permission"; // permission control

import * as directives from "@/directives";
// 注册自定义指令
// 遍历所有的导出的指令对象 完成自定义全局注册
Object.keys(directives).forEach((key) => {
  // 注册自定义指令
  Vue.directive(key, directives[key]);
});
import Component from "@/components";
Vue.use(Component); //注册自己的组件

import * as filters from "@/utils/filters/index";
//注册全局的过滤器 此刻filters是所有方法的集合
Object.keys(filters).forEach((key) => {
  Vue.filter(key, filters[key]);
});

//安装打印插件
import Print from "vue-print-nb";
Vue.use(Print);

//全局混入mixins
import checkPermission from "@/mixin/checkPermission";
Vue.mixin(checkPermission); //表示所有的组件都拥有了一个检查的方法

//引入i18n
import i18n from "@/lang";
/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online ! ! !
 */

// set ElementUI lang to EN
// Vue.use(ElementUI, { locale });
// 如果想要中文版 element-ui，按如下方式声明
Vue.use(ElementUI, {
  //element本身就支持i18n的处理
  //此时i18n就会根据当前的local属性去找对应显示的内容
  i18n: (key, value) => i18n.t(key, value),
});

Vue.config.productionTip = false;

new Vue({
  el: "#app",
  router,
  store,
  i18n,
  render: (h) => h(App),
});
